import { defineStore } from 'pinia'
import { ref } from 'vue'

export const mlxxMainStore = defineStore(
  'mlxx',
  () => {
    // 目录信息集合
    const mlxxData = ref<any>({})
    // 存储树节点
    const saveMlxxEvent = (data: any) => {
      mlxxData.value = data
    }

    // 保存归档状态
    const gdztData = ref<any>({})
    const savegdztData = (data: any) => {
      gdztData.value = data
    }
    const zzmlShow = ref<boolean>()
    const savezzml = (data: any) => {
      zzmlShow.value = data
    }

    // 我的借阅整理段数据
    const daxqData = ref<any>({})
    const saveDaxq = (data: any) => {
      daxqData.value = data
    }

    // 判断锁定状态=》是否只读
    const isUnlockReadOnly = ref<boolean>()
    const saveReadOnly = (data: any) => {
      isUnlockReadOnly.value = data
    }

    return {
      mlxxData,
      saveMlxxEvent,
      gdztData,
      savegdztData,
      zzmlShow,
      savezzml,
      daxqData,
      saveDaxq,
      isUnlockReadOnly,
      saveReadOnly,
    }
  },
  {
    // 持久化设置（默认存储sessionStorage，https://seb-l.github.io/pinia-plugin-persist/advanced/partial-state.html）
    persist: { enabled: true },
  },
)
